#include <iostream>
#include <algorithm>
using namespace std;

template <class T>
class MyArray
{
    private:
        T* data;
        int size;
    public:
        MyArray(int n):size(n)
        {
            data=new T[n];
            for (int i=0;i<n;i++)
            {
                cin>>data[i];
            }
        }
        void sort(){std::sort(data,data+size);}
        void display() const
        {
            for (int i=0;i<size;i++)
            {
                if (i==0)   cout<<data[0];
                else    cout<<" "<<data[i];
            }
            cout<<endl;
        }
        bool check();
        ~MyArray();        
    
};

template<class T>
MyArray<T>::~MyArray(){ delete[] data;}

template<class T>
bool MyArray<T>::check(){
    int i;
    for(i=0;i<size-1;i++)
        if(data[i]>data[i+1]) { cout<<"ERROR!"<<endl;return false;}
    return true;
}
int main( )
{
    MyArray<int> *pI;
    MyArray<float> *pF;
    MyArray<char> *pC;
    int ty, size;
    cin>>ty;
    while(ty>0){
        cin>>size;
        switch(ty){
            case 1: pI = new MyArray<int>(size);   pI->sort(); pI->check(); pI->display(); delete pI; break;
            case 2: pF = new MyArray<float>(size); pF->sort(); pF->check(); pF->display(); delete pF; break;
            case 3: pC = new MyArray<char>(size);  pC->sort(); pC->check(); pC->display(); delete pC; break;
        }
        cin>>ty;
    }
    return 0;
}